package gbench.appdemo.medicine.chemistry.solution;

import gbench.appdemo.medicine.chemistry.particle.Formula;
import gbench.appdemo.medicine.chemistry.particle.Particle;

/**
 * 微粒子
 * 
 * @author gbench
 *
 */
public class Solute extends Particle {

    /**
     * 
     * @param name
     */
    public Solute(String name) {
        super(name);
    }

    /**
     * 
     * @param name
     */
    public Solute(Particle particle) {
        super(particle);
    }

    /**
     * 
     * @param name
     */
    public Solute(Particle particle, double ratio) {
        super(particle);
        this.setRatio(ratio);
    }

    /**
     * 
     * @param name
     * @param ratio
     */
    public Solute(String name, double ratio) {
        this(name);
        this.setRatio(ratio);
    }

    /**
     * 
     * @return
     */
    public double getRatio() {
        return ratio;
    }

    /**
     * 
     * @param ratio
     */
    public void setRatio(double ratio) {
        this.ratio = ratio;
    }

    /**
     * 溶质浓度
     * 
     * @return
     */
    public double concentration() {
        return this.ratio;
    }

    public String toString() {
        return this.name + "[" + this.charge + "]" + ":" + this.ratio;
    }

    /**
     * 溶质
     * 
     * @param name
     * @return
     */
    public static Solute of(final String name) {
        final var bp = Formula.parse(name);
        final var particle = bp._1();
        return new Solute(particle, bp._2());
    }

    private double ratio; // 溶质占比
}
